/**
 * Copyright (c) 2006-2008, Julien PORTALIER
 * 
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @copyright  Copyright (c) 2006-2008, Julien PORTALIER
 * @link       http://feather-cm.google.com/
 * @license    http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 * 
 * @deprecated
 */

var Filer = {};

Filer.AddImageToPage = new Class(
{
	initialize: function(form)
	{
		this.form = $(form);
		
		// from toolbar?
		this.toolbar = window.parent.toolbarFiler;
		if (this.toolbar) 
		{
			this.filer = this.toolbar.filer;
			this.form.addEvent('submit', this.addToPage.bindWithEvent(this));
		}
		else {
			this.form.setStyle('display', 'none');
		}
		
		// popup to display full size image
		$E('p.url a').addEvent('click', this.showImage.bindWithEvent(this));
	},
	
	showImage: function(evt)
	{
		window.open(evt.target.getAttribute('href'), 'filer_show_image',
			'menubar=no,status=no,scrollbars=yes,toolbar=no,width=500,height=400');
		evt.stop();
	},
	
	addToPage: function(evt)
	{
		/*
		evt.stop();
		
		// elements
		var src     = this._value('path');
		var alt     = this._value('alt');
		var title   = this._value('title');
		var options = '';
		
		// describe
		if (alt)
			options += '|' + alt;
		if (title)
			options += '|' + title;
		
		// resize
		if ($E('[name=resize]').checked)
			options += '|' + this._value('size');
		
		// add to textarea
		this.toolbar.appendText("{{" + src + options + "}}\n");
		
		// continue or close filer?
//		if (!confirm('The image has been added to your page. \nDo you want to add more images?'))
//			this.filer.hide();
		if (confirm('The image has been added to your page. \nDo you want to close the filer?'))
			this.filer.hide();
		*/
	},
	
	/**
	 * @return String Value of form field.
	 * @param  String name Name of field.
	 */
	_value: function(name)
	{
		return $E('[name=' + name + ']',  this.form).value.trim();
	}
});

/*window.addEvent('domready', function() {
	new Filer.AddImageToPage($('addToPage'));
});*/